home *** CD-ROM | disk | FTP | other *** search
/ Champak 43 / Vol 43.iso / games / phit.swf / scripts / __Packages / CRandom.as < prev    next >
Encoding:
Text File  |  2007-07-13  |  668 b   |  33 lines

  1. class CRandom
  2. {
  3.    var _seed = 0;
  4.    function CRandom(seed)
  5.    {
  6.       if(seed != undefined)
  7.       {
  8.          this.SetSeed(seed);
  9.       }
  10.    }
  11.    function SetSeed(seed)
  12.    {
  13.       this._seed = seed;
  14.    }
  15.    function GetRandom(Void)
  16.    {
  17.       this._seed = (this._seed * 9301 + 49297) % 233280;
  18.       return this._seed / 233280;
  19.    }
  20.    function GetNumInRange(bottom, top)
  21.    {
  22.       return bottom + this.GetRandom() * (top - bottom + 1);
  23.    }
  24.    function GetIntInRange(bottom, top)
  25.    {
  26.       return int(bottom + this.GetRandom() * (top - bottom + 1));
  27.    }
  28.    function GetBoolean(Void)
  29.    {
  30.       return this.GetRandom() < 0.5;
  31.    }
  32. }
  33.